<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>修改轮播(精英团队)</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="${request.contextPath}/favicon.ico">
    <link href="${request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${request.contextPath}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${request.contextPath}/css/animate.css" rel="stylesheet">
    <link href="${request.contextPath}/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap-fileinput/css/fileinput.min.css">
    <link href="${request.contextPath}/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style>
        .ibox-border {
            border: 1px solid #39aef5;
        }
        .ibox-border > .ibox-content {
            padding: 5px;
        }
        .form-control:focus,
        .single-line:focus {
            border-color: #0e9aef !important;
        }
        .checkbox-inline {
            line-height: 5px;
        }
        .list-group {
            margin-bottom: 0;
            margin-top: -5px;
        }
        .list-group > .list-group-item {
            border: none;
            padding: 8px 0;
            margin-left: 13px;
            margin-right: 13px;
            border-bottom: 1px dashed #b4afaf;
            margin-bottom: 0;
        }
        .list-group > .list-group-item:nth-last-child(1) {
            border-bottom: none;
        }
        .teacms-tags-list-group {
            list-style: none;
            padding-left: 0;
        }
        .teacms-tags-list-group li {
            display: inline-block;
            margin-bottom: 5px;
            border: 1px solid #ccc;
            padding: 3px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">

    <div class="ibox float-e-margins ibox-blue">
        <div class="ibox-title">
            <h5>修改轮播（精英团队）</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a class="close-link">
                    <i class="fa fa-times"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form id="addForm" class="form-horizontal" autocomplete="off">
                <div class="col-md-12" style="padding: 0">
                    <input type="hidden" name="id" value="${team.id!}">
                    <div class="form-group">
                        <label for="firstname" class="col-sm-2 control-label">QQ地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teamUrl" maxlength="255" value="${team.teamUrl!}" placeholder="请输入QQ地址">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="firstname" class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="teamName" maxlength="255" value="${team.teamName!}" placeholder="请输入姓名">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="firstname" class="col-sm-2 control-label">排序号</label>
                        <div class="col-sm-10">
                            <input type="number" class="form-control" name="sort" maxlength="6" value="${team.sort!}" placeholder="请输入排序号">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">产品图片</label>
                        <input id="teamImg" type="hidden" name="teamImg" value="${team.teamImg!}">
                        <div class="col-sm-10">
                            <div class="file-loading">
                                <input id="fileUpload" type="file" name="file" multiple>
                            </div>
                        </div>
                    </div>

                </div>

                <button type="submit" class="btn btn-primary btn-block">提交</button>
            </form>
            <div class="clearfix"></div>
        </div>
    </div>

</div>


<!-- 全局js -->
<script src="${request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="${request.contextPath}/js/content.js?v=1.0.0"></script>
<script src="//unpkg.com/wangeditor/release/wangEditor.min.js"></script>
<script src="${request.contextPath}/plugins/bootstrap-fileinput/js/fileinput.min.js"></script>
<script src="${request.contextPath}/plugins/bootstrap-fileinput/js/locales/zh.js"></script>
<!-- Data picker -->
<script src="${request.contextPath}/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script>
    $(function () {

        function initFileInput(domId, uploadUrl) {
            var control = $('#' + domId);
            control.fileinput({
                language: "zh",
                uploadUrl: uploadUrl,
                browseClass: "btn btn-success",
                browseLabel: "选择产品预览图片",
                browseIcon: "<i class=\"glyphicon glyphicon-picture\"></i> ",
                allowedFileExtensions: ['jpg', 'gif', 'png'],
                showUpload: false,
                dropZoneEnabled: false,
                showPreview: true,
                minFileCount: 1,
                maxFileCount: 1,
                validateInitialCount:true,
                initialPreviewAsData: true,
                initialPreview: [
                  '/${team.teamImg!}'
                ],
                fileActionSettings : {
                    showRemove: false,
                    showZoom : true,
                    showUpload : false
                },
            });
            $(".kv-file-remove").remove();
        }

        initFileInput("fileUpload", "/admin/upload");
        $("#fileUpload").on("filebatchselected", function(event, files) {
            $(this).fileinput("upload");
        });
        $("#fileUpload").on("fileuploaded", function(event, data, previewId, index) {
            if (data.response.status) {
                $("#teamImg").val(data.response.filePath);
            } else {
                parent.layer.msg(data.response.msg, {time: 1500, icon:5});
            }
        });

        $("#addForm").submit(function (e) {
            e.preventDefault();
            // 产品图片
            var teamUrl = $("#addForm input[name='teamUrl']").val()
            if (teamUrl == "" || teamUrl == null) {
                parent.layer.msg("请输入QQ地址", {time: 1500, icon:5});
                return;
            }

            var sort = $("#addForm input[name='sort']").val()
            if (sort == "" || sort == null) {
                parent.layer.msg("请输入排序号", {time: 1500, icon:5});
                return;
            }

            var teamImg = $("#addForm input[name='teamImg']").val()
            if (teamImg == "" || teamImg == null) {
                parent.layer.msg("请上传轮播图片", {time: 1500, icon:5});
                return;
            }
            var teamName = $("#addForm input[name='teamName']").val()
            if (teamName == "" || teamName == null) {
                parent.layer.msg("请输入姓名", {time: 1500, icon:5});
                return;
            }


            $.ajax({
                url: "/admin/team/updateTeam",
                data:  $("#addForm").serialize(),
                type: "POST",
                dataType: 'json',
                success: function(data){
                    if (data.success) {
                        parent.layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    } else {
                        parent.layer.msg(data.msg, {time: 1500, icon:5});
                    }
                }
            });
        });

    })
</script>
</body>
</html>